import React from 'react'
import {
  autorun,
  observable,
  getObservableMaker,
  observe,
  define,
  reaction,
  Tracker,
} from '@formily/reactive'

const obs = observable<any>({})

// const view = () => {
//   console.log('tracker==: ', obs.value)
// }

/**
 * 嵌套更新
 * 首次执行 view 时，会进行更新
 */
const view = () => {
  obs.value = obs.value || 321
  console.log('tracker==: ', obs.value)
}

const scheduler = () => {
  console.log('tracker==:  -- scheduler')
  tracker.track(view)
}
const tracker = new Tracker(scheduler)

tracker.track(view)

setTimeout(() => {
  // obs.value = 123
}, 2000)

export default () => <div>tracker-test</div>
